﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Core.Common;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeavenDAL
{
    public class EquipmentDAL : BaseDAL
    {
        public List<Equipment> GetEquips(int page, int size)
        {
            if (page <= 0)
            {
                page = 1;
            }
            string sql = @"select * from (
select [ID],[Name],[Price],[Description],[Type],[OverDue],[Status],[SubmitTime],[Image]
,ROW_NUMBER() OVER(ORDER BY ID DESC) ROW 
from Equipment) FF
 WHERE FF.ROW BETWEEN  @p0 AND @p1";
            List<Equipment> list = dbOper.Query<Equipment>(sql, size * (page - 1)+1, size * page);
            return list;
        }

        public int GetTotalSize()
        {
            string sql = @"select count(id) from Equipment ";
            return dbOper.GetScalar<int>(sql);
            
        }
    }
}
